﻿
@{
    ViewBag.Title = "_Add";
}
@using Shop.Entity;
@model TArticleCategory
<script src="/Content/Validform_v5.3.2/Validform_v5.3.2_min.js"></script>
<script src="~/Content/layer/layer.js"></script>
<div class="modal fade" id="Add" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="headerTitle">新增分类</h4>
            </div>
            <div class="modal-body">
                <div class="portlet-body form">
                    @using (Html.BeginForm("Add", "ArticleCategory", FormMethod.Post, new { id = "add", @class = "form-horizontal" }))
                    {

                        @Html.HiddenFor(c => c.Guid)
                        @Html.HiddenFor(c => c.AddTime)
                        @Html.HiddenFor(c => c.OperatorGuid)
                        @Html.HiddenFor(c => c.BusinessGuid)
                        @Html.HiddenFor(c => c.ChainStoreGuid)
                        <div class="form-body">
                            <div class="row">

                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        分类名称<span class="required"> * </span>
                                    </label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control input-sm input-inline" name="Title" id="Title" datatype="s2-30" nullmsg="请输入分类名称!" sucmsg=" " errormsg="名称至少2个字符,最多30个字符！" value="@Model.Title" />
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        显示顺序<span class="required"> * </span>
                                    </label>
                                    <div class="col-sm-5">
                                        <input type="text" class="form-control input-sm input-inline" name="Sort" id="Sort" datatype="n" nullmsg="请输入显示顺序!" sucmsg=" " errormsg="请输入数字!" value="@Model.Sort" />
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <label class="control-label col-sm-3">
                                        备注
                                    </label>
                                    <div class="col-sm-6">
                                        <textarea class="form-control input-sm" rows="3" cols="20" id="Remark" name="Remark" ignore="ignore" datatype="*1-200" errormsg="备注不能超过200个字符!" sucmsg=" ">@Model.Remark</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <label for="message-text" class="col-sm-3 control-label"></label>
                                    <div class="col-sm-6" id="tip">
                                        &nbsp;
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <input type="submit" class="btn btn-primary" value="保存" />
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    }
                </div>
            </div>

        </div>

    </div>
</div>

<script type="text/javascript">
    $('#Add').on('hidden.bs.modal', function (e)
    {
        layer.closeAll('tips'); //关闭所有的tips层
    })
    function ShowValidformMsg(msg, id)
    {
        layer.tips(msg, '#' + id, { tipsMore: true });
    }
    $(function ()
    {
        $("#add").Validform({
            showAllError: true,
            ajaxPost: true,
            beforeSubmit: function (curform)
            {
                layer.msg('正在执行操作...', { icon: 16 });
                return true;
            },
            callback: function (data)
            {
                if (data.succ)
                {
                    layer.msg('保存成功!', { icon: 1 });
                    $("#Add").modal('hide');
                    parent.layer.closeAll();
                    $(".pagination .active").find("a").click();
                }
            },
            tiptype: function (msg, o)
            {
                if (msg.trim() != "" && o.type != 1)
                { ShowValidformMsg(msg, $(o.obj).attr("id")); }
            }
        }
     );
    })

</script>